angular.module('common.controllers', [])

//我的账号
.controller('AccountCtrl', function($scope, $rootScope,$location) {
  $scope.$on('$ionicView.enter', function(e) {

    $scope.account = Meteor.user();
   
  });
  $rootScope.isEdit=$location.search().isEdit || false;

  $scope.isBlockShown=true;
  $scope.toggleFeilds = function(){
    $scope.isBlockShown = !$scope.isBlockShown;
  };
 

})
//重置密码
.controller('PwresetCtrl', function($scope, $state, $location, $timeout) {
  
})
//修改密码
.controller('PwmodifyCtrl', function($scope, $state, $location, $timeout) {
  $scope.data={
    oldPassword:'',
    newPassword:''
  };
 
	$scope.modPassword = function() {
    Accounts.changePassword($scope.data.oldPassword,$scope.data.newPassword);
		$timeout(function() {
			window.location.href='#/home';
		}, 1000);
	};
})

// 注销登录，共用
.controller('LogoutCtrl', function($scope,$meteor,$timeout) {

  $scope.logout = function(){
    $meteor.logout().then(function() {
      window.location.href='index.html';
    }, function(err) {
      console.error('退出时发生错误 : ', err.reason);
    });
  };
});
